import tensorflow as tf
import util.data_helper as data_helper
import util.PATH as PATH
import numpy as np
from deeptriage.BiRNN import BiRNN
import os
import time
import datetime

bug_msg_all, _ = data_helper.get_msg_all()
vocabulary = data_helper.create_vocabulary()
developers_list = data_helper.create_developers_list()

num_classes = len(developers_list)
vocabulary_size = len(vocabulary)
developers_size = len(developers_list)
time_windows = data_helper.split_dataset_by_time_windows(bug_msg_all)

def get_active_sequence_vec_by_bug_id(current_id):
	# active_sequence = []    # 开发者由远及近, -1位置的最近
	active_vec = []         # 替换成数字索引得到的vector向量
	with open(PATH.path_active_list + current_id, 'r') as reader:
		for line in reader.readlines():
			active_vec.append(line.strip())
	return active_vec

def get_active_num(index):

	num = 0
	nums = {}

	for i in range(len(time_windows[index])):
		count = len(get_active_sequence_vec_by_bug_id(time_windows[index][i]))
		if count in nums.keys():
			nums[count] += 1
		else:
			nums[count] = 1
		if count == 0:
			num += 1
	return num, nums

if __name__ == '__main__':
	nums_0 = 0
	for i in range(10):
		num, nums = get_active_num(i)
		# print(num)
		print('窗口{}:{}'.format(i,nums))
		nums_0 += num
	print(nums_0)